/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import service.inventory.*;
import service.promo.PromoDisitemService;
import service.promo.PromoDistrukService;
import service.promo.PromoPriceService;
import service.promo.PromoService;
import service.publics.SupplierService;
import service.publics.WorkstationService;
import service.purchasing.OrderService;
import service.purchasing.TorderService;
import service.sales.MembersService;
import service.sales.SalesInitService;
import service.sales.SalesSavingService;
import service.sales.SalesService;
import service.sales.SalesVoidService;
import service.sales.SalespendingService;
import service.system.*;
import view.system.LoginFrm;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class Office {
   
    private static LoginFrm frame;
    
    public static LoginFrm getFrame() {
        return frame;
    }

    public static void setFrame(LoginFrm frame) {
        Office.frame = frame;
    }
    
    public static void main(String[] args) {
         try { 
       //    WindowsLookAndFeel lnfName = new WindowsLookAndFeel();
           UIManager.setLookAndFeel( new WindowsLookAndFeel());
         //    UIManager.setLookAndFeel(new Office2003LookAndFeel());
           //UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
                     
        } catch (UnsupportedLookAndFeelException e) {}
                
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                
               //server-client-mode 
               ApplicationContext applicationContext =
                       new ClassPathXmlApplicationContext("applicationContext.xml");
               
               //three-tier-mode  
//                ApplicationContext applicationContext =
//                        new ClassPathXmlApplicationContext("clientContext.xml");
                
                ServicesList.setLocal();
                ServicesList.setSystemMenuService((SystemMenuService) applicationContext.getBean("systemMenuService"));
                ServicesList.setSupplierService((SupplierService) applicationContext.getBean("supplierService"));
                ServicesList.setItemService((ItemService) applicationContext.getBean("itemService"));
                ServicesList.setUnitService((UnitService) applicationContext.getBean("unitService"));
                ServicesList.setPrincipalService((PrincipalService) applicationContext.getBean("principalService"));
                ServicesList.setPackagingService((PackagingService) applicationContext.getBean("packagingService"));
                ServicesList.setDeptService((DeptService) applicationContext.getBean("deptService"));
                ServicesList.setSystemGroupService((SystemGroupService) applicationContext.getBean("systemGroupService"));
                ServicesList.setSystemGroupAccessService((SystemGroupAccessService) applicationContext.getBean("systemGroupAccessService"));
                ServicesList.setSystemUserService((SystemUserService) applicationContext.getBean("systemUserService"));
                ServicesList.setHadiahService((HadiahService) applicationContext.getBean("hadiahService"));
                ServicesList.setMembersService((MembersService) applicationContext.getBean("membersService"));
                ServicesList.setItemHppService((ItemHppService) applicationContext.getBean("itemHppService"));
                ServicesList.setItemSupplierService((ItemSupplierService) applicationContext.getBean("itemSupplierService"));
                ServicesList.setOrderService((OrderService) applicationContext.getBean("orderService"));
                ServicesList.setTorderService((TorderService) applicationContext.getBean("torderService"));
                ServicesList.setSystemNumberingService((SystemNumberingService) applicationContext.getBean("systemNumberingService"));
                ServicesList.setItemStokService((ItemStokService) applicationContext.getBean("itemStokService"));
                ServicesList.setItemPriceService((ItemPriceService) applicationContext.getBean("itemPriceService"));
                ServicesList.setCompanyService((CompanyService) applicationContext.getBean("companyService"));
                ServicesList.setPromoService((PromoService) applicationContext.getBean("promoService"));
                ServicesList.setPromoPriceService((PromoPriceService) applicationContext.getBean("promoPriceService"));
                ServicesList.setPromoDisitemService((PromoDisitemService) applicationContext.getBean("promoDisitemService"));
                ServicesList.setPromoDistrukService((PromoDistrukService) applicationContext.getBean("promoDistrukService"));
                ServicesList.setSalesService((SalesService) applicationContext.getBean("salesService"));
                ServicesList.setSalesInitService((SalesInitService) applicationContext.getBean("salesInitService"));
                ServicesList.setSalesVoidService((SalesVoidService) applicationContext.getBean("salesVoidService"));
                ServicesList.setSalespendingService((SalespendingService) applicationContext.getBean("salespendingService"));
                ServicesList.setSalesSavingService((SalesSavingService) applicationContext.getBean("salesSavingService"));
                ServicesList.setWorkstationService((WorkstationService) applicationContext.getBean("workstationService"));
                ServicesList.setAdjService((AdjMstService) applicationContext.getBean("adjMstService"));
                ServicesList.setSystemReportService((SystemReportService)applicationContext.getBean("systemReportService"));
                
                frame = new LoginFrm();
                frame.appCaller = "OFFICE";
                frame.setVisible(true);
            }
        });
    }
}
